package com.xuqi.Game.Tetris;

import javax.security.auth.PrivateCredentialPermission;

import com.xuqi.R;
import com.xuqi.menucontrol.MenuControlIF;

import android.R.integer;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.util.Log;

public class ElementCombination
{
	public ElementCombination()
	{
		super();
		// TODO Auto-generated constructor stub
	}

	public static void DrawBackGround(Canvas canvas)
	{
		canvas.drawARGB(255, 255, 255, 255);
	}
	public static void DrawElement(Canvas canvas, int letf, int top)
	{
		ElementInfo elementInfo = new ElementInfo();
		canvas.drawBitmap(elementInfo.m_Element, LEFT(letf), TOP(top), null);
	}

	public static void DrawShape(Canvas canvas, ShapeInfo spinfo, int left, int top)
	{
		int dir = spinfo.m_Dir_Kind;
		int shape = spinfo.m_Shape_Kind;

		for (int x = 0; x < ShapeInfo.m_Shape_X; x++)
		{
			for (int y = 0; y < ShapeInfo.m_Shape_Y; y++)
			{
				int i = x * ShapeInfo.m_Shape_X + y;
				if (spinfo.shapes[shape][dir][i] == 1)
				{
					DrawElement(canvas, left + x, top + y);
				}
			}
		}
	}

	public static int LEFT(int left)
	{
		return left * ElementInfo.width;
	}

	public static int TOP(int top)
	{
		return top * ElementInfo.height;
	}

	public static class ElementInfo
	{
		public ElementInfo()
		{
			super();
			// TODO Auto-generated constructor stub
			// m_Element =
			// BitmapFactory.decodeResource(MenuControlIF.GetCurActivity().getResources(),R.drawable.icon);
			m_Element = Bitmap.createBitmap(width, height, Config.ARGB_8888);
			Canvas canvas = new Canvas(m_Element);
			canvas.drawARGB(255, 255, 255, 255);
			Paint paint = new Paint();
			paint.reset();
			paint.setARGB(255, 0, 0, 0);
			Rect rect = new Rect(2, 2, width - 2, height - 2);
			canvas.drawRect(rect, paint);
			//
		}

		public Bitmap m_Element = null;
		public static int width = 20;
		public static int height = 20;
	}

}
